// 获取元素
// 头部
var header = document.querySelector("#header");
// 轮播图
var Shuffling = $("#Shuffling");
// a标签
var as = $(".header_mainbav a");
// 扫码
var sweep = document.querySelector(".header_sweep");
// 二维码
var dcode = document.querySelector(".dcode");
// 图标
var loge = document.querySelector(".header_loge img");
// 横线
var header_nav = $(".ens");
// 容器
var header_mainbav = $(".header_mainbav");
// 加入
var join = document.querySelector("#header .header_join");
// 容器
var jh = document.querySelector("#header .jh");
// 加盟
var hz = $(".hz");
var jr = $(".jr");
var as1 = $(".header_join .hz a");
var as2 = $(".header_join .jr a");

// 扫码划入划出事件
sweep.onmouseover = function(){
    dcode.style.display = "block";
}
sweep.onmouseout = function(){
    dcode.style.display = "none";
}
// 加盟划入划出事件
join.onmouseover = function(){
    jh.style.display = "block";
}
join.onmouseout = function(){
    jh.style.display = "none";
}
// a标签划入划出事件
as1.css("color","black");
hz.on("mouseover",function(){
    as1.css("color","white");
})
hz.on("mouseout",function(){
    as1.css("color","black");
})
as2.css("color","black");
jr.on("mouseover",function(){
    as2.css("color","white");
})
jr.on("mouseout",function(){
    as2.css("color","black");
})
// 执行插件内的函数
$('.carousel').carousel();

function hover1(){
    as.on("mouseover",function(){
        $(this).addClass("addclass");
    });
    as.on("mouseout",function(){
        as.removeClass("addclass");
    });
}
hover1();
// 滚动监听事件
window.onscroll = function(){
    if (document.body.scrollTop > Shuffling.height()) {
        loge.setAttribute("src","img/logo.png");
        header.style.background = "RGBA(248, 248, 248, 0.6)";
        as.addClass("addclass1");
    }else {
        loge.setAttribute("src","img/logo1.png");
        header.style.background = "rgba(20, 20, 20, 0.498039)";
        as.removeClass("addclass1");
        as1.css("color","black");
        as2.css("color","black");
        hover1();
    }
}
// 显示隐藏事件
var fals = true;
header_nav.on("click",function(){
    if (fals == true) {
        header_mainbav.slideDown("slow");
        fals = false;
    }else {
        header_mainbav.slideUp("slow");
        fals =true;
    }
})
